#include <iostream>
using namespace std;
#include <unistd.h>
#include <sys/types.h>

int main()
{

    printf("I am process, pid: %d, ppid：%d\n",getpid(),getppid());
    pid_t id = fork();
    if (id > 0)
    {
        while(1)
        {
            printf("我是父进程!,pid：%d,ppid：%d,id: %d\n",getpid(),getppid(),id);
            sleep(2);
            cout << endl;
        }
    }
    else if(id == 0)
    {

        while(1)
        {
            printf("我是子进程!,pid：%d,ppid：%d,id: %d\n",getpid(),getppid(),id);
            sleep(2);
            cout << endl;
        }
    }
    //printf("I am process, pid: %d, ppid：%d\n",getpid(),getppid());
    return 0;
}
